package com.huawei;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @description:
 * @author: HuangJiaxin
 * @create: 2022-04-22 16:55
 **/
public class HJ022 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        ArrayList<Integer> list = new ArrayList<>();
        while(scanner.hasNextInt()){
            int input = scanner.nextInt();
            if(input == 0){
                break;
            }
            list.add(getNum(input));
        }
        for (Integer integer : list) {
            System.out.println(integer);
        }


    }

    public static int getNum(int num){
        int count = 0;
        while(num/3 != 0){
            int temp = num /3;
            count += temp;
            num = num % 3 + temp;
            if(num == 1){
                break;
            }else if(num ==2){
                count ++;
                break;
            }
        }
        return count;

    }

}
